package com.example.boot.repository

import com.example.boot.domain.SettingsV2
import org.hibernate.type.BigIntegerType
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional
import java.math.BigInteger

@Repository
interface SettingsRepositoryV2 : JpaRepository<SettingsV2, BigInteger> {
    @Query(value = "select nextval ('s_settings')", nativeQuery = true)
    fun getId(): BigInteger

    @Transactional
    @Modifying
    @Query(value = "insert into t_settings_v2 (name, value, id) values (?1, ?2, ?3)", nativeQuery = true)
    fun insertSettings(@Param("name") name: String, @Param("value") value: String, @Param("id") id: BigInteger)


    @Transactional
    @Modifying
    @Query(value = "insert into t_settings_v2 (name, value) values (:name, :value)", nativeQuery = true)
    fun insertSettings(@Param("name") name: String, @Param("value") value: String)


}